
pub const fn parse_usize(s: &str) -> usize {
    let bytes = s.as_bytes();
    let mut value: usize = 0;
    let mut i = 0;
    while i < bytes.len() {
        let n = bytes[i];
        if (n >= b'0') && (n <= b'9') {
            value = value * 10 + ((n - b'0') as usize);
        } else if (n == b'k') || (n == b'K') {
            value *= 1024;
            break;
        } else {
            panic!("parse_usize invalid")
        }
        i += 1;
    }
    value
}

pub const fn parse_usize16(s: &str) -> usize {
    let bytes = s.as_bytes();
    let mut value: usize = 0;
    let mut i = 0;
    while i < bytes.len() {
        let n = bytes[i];
        if (n >= b'0') && (n <= b'9') {
            value = value * 16 + ((n - b'0') as usize)
        } else if (n >= b'a') && (n <= b'f') {
            value = value * 16 + ((10 + n - b'a') as usize);
        } else if (n >= b'A') && (n <= b'F') {
            value = value * 16 + ((10 + n - b'A') as usize);
        } else {
            panic!("parse_usize16 invalid")
        }
        i += 1
    }
    value
}
